package com.eaoa.uc.address.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eaoa.base.EABaseAction;
import com.eaoa.query.pub.PubAddressQuery;
import com.eaoa.query.pub.PubCityQuery;
import com.eaoa.uc.address.form.HRAddressModifyForm;
import com.eaoa.vo.pub.PubAddress;
import com.stony.core.util.CoreUtils;

public class HRAddressModifyPreAction  extends EABaseAction {
	
	protected ActionForward doWork(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		HRAddressModifyForm myform = (HRAddressModifyForm) form;
		Long addressno = CoreUtils.parseLong(myform.getAddressno());
		if (!isReEntry(request) && addressno != null) {
			PubAddress vo=PubAddressQuery.loadByNo(addressno);
			myform.setVO(vo);
		}
		
		Long provinceno = CoreUtils.parseLong(myform.getProvince());
		request.setAttribute("city", PubCityQuery.getCitys(provinceno, new Long(2)));

		Long cityno = CoreUtils.parseLong(myform.getCity());
		request.setAttribute("district", PubCityQuery.getCitys(cityno, new Long(3)));

		return mapping.findForward("success");
	}
}